// File:    TnSave.cs
// Author:  HT
// Created: Tuesday, October 18, 2011 2:13:44 PM
// Purpose: Definition of Class TnSave

using System;
using System.Collections.Generic;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Geometry;

namespace Tayninh2011
{

    public class TnSave : ITnSave
    {
        private List<string[]> listNeedSaved;

        public TnSave()
        {
            listNeedSaved = new List<string[]>();
        }

        #region ITnSave Members

        List<string[]> ITnSave.listNeedSaved
        {
            get
            {
                return this.listNeedSaved;
            }
            set
            {
                this.listNeedSaved = value;
            }
        }

        void ITnSave.SetVal(ref TnGeoObject geoObject, string fieldName, object value)
        {
            geoObject.Row.set_Value(geoObject.Row.Fields.FindField(fieldName), value);
            geoObject.Row.Store();
        }

        void ITnSave.SetVal(ref TnGeoObject geoObject)
        {
            foreach (string[] param in this.listNeedSaved)
            {
                geoObject.Row.set_Value(geoObject.Row.Fields.FindField(param[0]), param[1]);

            }
            geoObject.Row.Store();
        }

        void ITnSave.SetVal(ref TnGeoObject geoObject,List<string[]> listParam,string typeOfObject)
        {
            if (typeOfObject == "feature")
            {
                foreach (string[] param in listParam)
                {
                    geoObject.Feature.set_Value(geoObject.Feature.Fields.FindField(param[0]), param[1]);

                }
                geoObject.Feature.Store();
            }
            else if (typeOfObject == "row")
            {
                foreach (string[] param in listParam)
                {
                    geoObject.Row.set_Value(geoObject.Row.Fields.FindField(param[0]), param[1]);

                }
                geoObject.Row.Store();
            }
        }
        void ITnSave.SetVal(ref TnGeoObject geoObject, List<object[]> listParam,string typeOfObject)
        {
            if (typeOfObject=="feature")
            {
                foreach (object[] param in listParam)
                {
                    geoObject.Feature.set_Value(geoObject.Feature.Fields.FindField(param[0].ToString()), param[1]);

                }
                geoObject.Feature.Store();
            }
            else if (typeOfObject=="row")
            {
                foreach (object[] param in listParam)
                {
                    geoObject.Row.set_Value(geoObject.Row.Fields.FindField(param[0].ToString()), param[1]);

                }
                geoObject.Row.Store();
            }
        }



        #endregion
    }
}
